<?php
/**
 *    Copyright 2010 Show Framework(www.showframework.cn)
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 * 
 *        http://www.apache.org/licenses/LICENSE-2.0
 * 
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

/**
 * 展现形式为html的视图
 *
 * @package Show_View
 * @name Show_View_Html
 * @author show
 * @since v0.6
 */
class Show_View_Html extends Show_View
{
    /**
     * html模板路径
     *
     * @var string
     */
    private $path;
    
    /**
     * 展现视图
     * 
     * @return void
     */
    public function show()
    {
        extract($this->getPropertys(), EXTR_OVERWRITE);
        include_once $this->path;
        exit();
    }
    
    /**
     * 设置此视图的html文件
     * 本视图是用html作为展现形式的，因此要设置一个html文件，可以把这个文件理解为模板
     * 注意：如果html中还嵌入了php代码，最好用.php作为后缀名，以防直接访问html的时候暴露php代码
     * 这个路径要注意安全问题，不要用用户提交的路径作为参数，用户可能使用恶意的路径
     * 
     * @param string $path 相对于 HTML_PATH 的路径
     * @return void
     */
    public function setHtml($path)
    {
        $this->path = WEB_ROOT . 'html/' . $path;
    }
}
?>